package org.zht.dormpro.dorm.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.socket.TextMessage;
import org.zht.dormpro.dorm.websocket.SocketHandler;
import org.zht.dormpro.pub.ResponseMap;

@Controller
@RequestMapping("/dorm/socket")
public class SocketController {
    @Autowired
    private SocketHandler socketHandler;
    @RequestMapping("sendMess")
    @ResponseBody
    public ResponseMap sendMessage() throws Exception {
        socketHandler.sendMsgToAllUsers(new TextMessage("测试消息"));
        return ResponseMap.success("success");
    }
    @RequestMapping("htm")
    public String sendMessage2() {
        return "testsocket";
    }
}
